package org.example.seata.bs.api.feign.account;

import org.example.seata.bs.api.dto.account.AccountBalanceLogDto;
import org.example.seata.bs.api.feign.account.factory.RemoteAccountServiceFallbackFactory;
import org.example.seata.bs.api.vo.account.AccountBalanceLogVo;
import org.example.seata.bs.api.vo.account.AccountVo;
import org.example.seata.common.core.constant.SecurityConst;
import org.example.seata.common.core.constant.ServiceModuleConst;
import org.example.seata.common.core.util.ApiResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * @author hzq
 * @date 2021/11/30 16:22
 */
@FeignClient(
        value = ServiceModuleConst.ACCOUNT_SERVICE,
        fallbackFactory = RemoteAccountServiceFallbackFactory.class
)
public interface RemoteAccountService {

    /**
     * 减用户余额
     *
     * @param dto 信息
     * @return 操作结果
     */
    @PostMapping("/account/minusAccountBalance")
    ApiResp<AccountBalanceLogVo> minusAccountBalance(@RequestBody AccountBalanceLogDto dto);

    /**
     * 获取用户信息
     * 测试 OAuth2FeignRequestInterceptor 服务调用的时候有没有拷贝token 进行传递
     *
     * @return 用户信息
     */
    @GetMapping("/account")
    ApiResp<AccountVo> getInfo();

    @PutMapping("/account")
    ApiResp putInfo(@RequestHeader(SecurityConst.FROM) String from);
}
